<!--
 * @Description: 
 * @LastEditors: xzh
 * @LastEditTime: 2024-06-10 10:29:14
-->
<template>
  <DileLayer
    v-model="visible"
    layerWidth="80%"
    layerHeight="70%"
    :footerVisible="false"
  >
    <!-- 快捷入口动态组件 -->
    <component :is="enterComponent" />
  </DileLayer>
</template>

<script setup lang="ts">
import { ref, reactive, computed, defineAsyncComponent } from "vue";
import DileLoading from "@/components/dile-loading/index.vue";

let modeType = ref<string>("");

let visible = ref<boolean>(false);

/**
 * @Author: xzh
 * @Description: 初始化
 * @Param:
 * @param {*} code
 */
let init = (code: string) => {
  modeType.value = code;
  visible.value = true;
};

/**
 * @Author: xzh
 * @Description: 动态组件
 * @Param:
 * @param {*} computed
 */
let enterComponent = computed(() => {
  let asyncImport: Function | any = null;
  switch (modeType.value) {
    case "equipArchives":
      //设备资料
      asyncImport = import(
        "@/views/equipManage/equipBaseInfo/equipArchives/index.vue"
      );
      break;
    case "spareInfo":
      //备品备件资料
      asyncImport = import(
        "@/views/equipManage/equipSpare/spareLedger/index.vue"
      );
      break;
    case "upKeepInfo":
      //设备维护保养资料
      asyncImport = import(
        "@/views/equipManage/equipUpkeep/upkeepRecord/index.vue"
      );
      break;
    case "alarmInfo":
      //设备异常报警信息
      asyncImport = import("@/views/abnormalManage/equipAbnormal/index.vue");
      break;
    case "moldInfo":
      //模具资料
      asyncImport = import(
        "@/views/moldManage/moldBaseInfo/moldArchives/index.vue"
      );
      break;
  }

  return !!asyncImport
    ? defineAsyncComponent({
        loader: () => asyncImport,
        loadingComponent: DileLoading,
      })
    : null;
});

defineExpose({
  init,
});
</script>
<style lang="scss" scoped></style>
